<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>收货地址</title>
	<script th:src="@{/layui/layui.js}" type="text/javascript"></script>
	<link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
</head>
	<body>
		<div class="layui-panel" style="padding: 8px;">
			<fieldset class="layui-elem-field layui-border-green">
				<legend>搜索信息</legend>
				<form class="layui-form layui-pane" style="margin: 20px;">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">名称</label>
							<div class="layui-input-inline">
								<input class="layui-input" type="text" name="name" autocomplete="off"/>
							</div>
						</div>
						<div class="layui-inline">
							<div class="layui-input-inline">
								<a class="layui-btn layui-btn-primary" lay-submit="" lay-filter="searchBtn">
									<i class="layui-icon layui-icon-search"></i>
									搜索
								</a>
							</div>
						</div>
					</div>
				</form>
			</fieldset>
			<script id="tableBar" type="text/html">
				<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="add">
					<i class="layui-icon layui-icon-add-circle"></i>
					新增
				</a>
			</script>

			<div>
				<table id="addressTable" lay-filter="addressTable"></table>
			</div>
		</div>
	<script>
		var data = [
		{"id":"1","name":"李明","phone":"15907796463","aAddress":"广西贵港市港南区","dAddress":"详细地址","default":"是",}
		]
		layui.use(['table','form','layer'],function(){
			var table = layui.table,form = layui.form,
			layer=layui.layer;
			
			//加载表格
			table.render({
				elem:'#addressTable',
				height:'full-160',
				toolbar:'#tableBar',
				page:true,
				url:'/mac/addressFind',
				cols:[
						[
				{field:'aid',title:'地址ID',width:100,sort:true},
				{field:'mid',title:'用户ID',width:100},
				{field:'name',title:'收件人名称',width:100,
					templet:function (res) {
						return res.address[0].name;
					}
				},
				{field:'phone',title:'手机号码',width:130,
					templet:function (res) {
						return res.address[0].phone;
					}
				},
				{field:'aAddress',title:'区域地址',width:150,
					templet:function (res) {
						return res.address[0].aaddress;
					}
				},
				{field:'dAddress',title:'详细地址',width:150,
					templet:function (res) {
						return res.address[0].daddress;
					}
				},
				{field:'aDefault',title:'默认',width:70,
					templet:function (res) {
						return res.address[0].adefault;
					}
				}

				]
				],
				data:data
			})
			var active ={
				add:function (content) {
					var b = false;
					top.layer.open({
						type:2,
						content:content,
						area:['700px','650px'],
						btn:['确认保存','取消关闭'],
						btn1:function (i,o) {
							b = true;
							o.find('iframe')[0].contentWindow.btnSubmit();
						},
						end:function () {
							if (b) layui.table.reload('addressTable');
						}
					})
				}
			}
			table.on('toolbar(addressTable)',function (obj) {
				var event = obj.event;
				if ('add'==event){
					active.add('/page/system/addressAdd');
				}
			})

		})
	</script>
	</body>
</html>
